//
//  UIButton+ZCorners.swift
//  AGF
//
//  Created by CS001 on 2021/3/17.
//

import UIKit
import BWToolKit

extension UIButton {
    @objc public class func setupZCornersAndGradient() {
        let cls = Self.self
        Objcer.swizzleSelector1(#selector(layoutSubviews), inClass1: cls, withSelector2: #selector(selfLayoutSubviews), inClass2: cls)
    }
    
    @objc private func selfLayoutSubviews(){
        selfLayoutSubviews()
        
        if zCornersEnabled {
            buildZCorners()
        }
        if zGrEnabled, let glayer = zGradientLayer {
            glayer.frame = bounds
            layer.insertSublayer(glayer, at: 0)
        }
    }
}
